home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / ISSUE22 / CLINIC / Menus2 / MenuFix.pas next >
Encoding:
Pascal/Delphi Source File  |  1997-04-24  |  1.1 KB  |  63 lines

  1. unit MenuFix;
  2.  
  3. interface
  4.  
  5. implementation
  6.  
  7. uses
  8.   SysUtils, Forms, Messages, Controls;
  9.  
  10. type
  11.   TFixMyMenus = class
  12.   private
  13.     function DoAppMessage(var Msg: TMessage): Boolean;
  14.   public
  15.     constructor Create;
  16.     destructor Destroy; override;
  17.   end;
  18.  
  19. constructor TFixMyMenus.Create;
  20. begin
  21.   inherited Create;
  22.   Application.HookMainWindow(DoAppMessage)
  23. end;
  24.  
  25. destructor TFixMyMenus.Destroy;
  26. begin
  27.   Application.UnhookMainWindow(DoAppMessage);
  28.   inherited Destroy
  29. end;
  30.  
  31. function TFixMyMenus.DoAppMessage(var Msg: TMessage): Boolean;
  32. begin
  33.   Result := (Msg.Msg = cm_AppSysCommand)
  34. {$ifndef CompletelyStopMenuRedirections}
  35.     and (Screen.ActiveForm.Menu <> nil)
  36. {$endif}
  37. end;
  38.  
  39. const
  40.   Obj: TFixMyMenus = nil;
  41.  
  42. procedure MyExitProc; far;
  43. begin
  44.   if Assigned(Obj) then
  45.     Obj.Free
  46. end;
  47.  
  48. {$ifdef Ver80} {Delphi 1.0x}
  49.   {$define DodgyMenus}
  50. {$endif}
  51. {$ifdef Ver90} {Delphi 2.0x}
  52.   {$define DodgyMenus}
  53. {$endif}
  54. {$ifdef Ver93} {C++ Builder 1.0x}
  55.   {$define DodgyMenus}
  56. {$endif}
  57.  
  58. initialization
  59. {$ifdef DodgyMenus}
  60.   AddExitProc(MyExitProc);
  61.   Obj := TFixMyMenus.Create
  62. {$endif}
  63. end.